<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="box">点击一下</button>
    <script>
        var arr = [-3, 5, 10, 6, -8];

        for (var i = 1; i <= arr.length; i++) {
            for (var j = 1, k = 0; j <= arr.length - i; j++, k++) {
                if (arr[k] > arr[k + 1]) {
                    var temp = arr[k];
                    arr[k] = arr[k + 1];
                    arr[k + 1] = temp;
                }

            }
        }
        console.log(arr);


        //
        var arr = [1, "a", "b", 3, "d", 5, 0];

        var numberArr = [];
        var stringArr = [];

        for (var i = 0; i < arr.length; i++) {
            if (typeof arr[i] == 'number') {
                numberArr.push(arr[i])
            } else if (typeof arr[i] == 'string') {
                stringArr.push(arr[i])

            }
        }

        console.log(numberArr);

        console.log(stringArr);


        //定义一个数组
        var names = ['Tom', 'Jack', 'Lily', 'Peter'];

        var btn = document.getElementById('box');

        btn.onclick = function() {
            var index = parseInt(Math.random() * name.length)
        }

        console.log(index[index]);
    </script>
</body>

</html>